package com.dex4d.dialog;

import android.content.Context;
import com.dex4d.R;

public class LoadingManager {

    private LoadingDialog dialog;//全局加载dialog

    private Context mContext;

    public LoadingManager(Context context) {
        this.mContext = context;
        LoadingDialog.Builder loadBuilder = new LoadingDialog.Builder(mContext)
                .setMessage(mContext.getResources().getString(R.string.loading_text))
                .setCancelable(false)
                .setCancelOutside(false);
        dialog = loadBuilder.create();
    }

    /**
     * 显示dialog
     */
    public void showLoadingDialog() {
        if (null != dialog && !dialog.isShowing()) {
            dialog.show();
        }
    }

    /**
     * 关闭dialog
     */
    public void dismissLoadingDialog() {
        if (null != dialog && dialog.isShowing()) {
            dialog.dismiss();
        }
    }

}
